// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import Vuex from 'vuex'
// import store from './vuex/store'
import FastClick from 'fastclick'
import VueRouter from 'vue-router'
import App from './App'
 
import congig from './config/config.js'
window.config = congig

//发送请求;
import VueResource from 'vue-resource'

import Icon from 'vue-svg-icon/Icon.vue';
Vue.component('icon', Icon); 
  
Vue.use(VueRouter)
Vue.use(Vuex)
Vue.use(VueResource);

// import { AjaxPlugin } from 'vux'
// Vue.use(AjaxPlugin)发送请求的

import  { ConfirmPlugin } from 'vux'
Vue.use(ConfirmPlugin)

import  { ToastPlugin } from 'vux'
Vue.use(ToastPlugin)

const store = new Vuex.Store({}) // 这里你可能已经有其他 module

store.registerModule('vux', { // 名字自己定义
  state: {
    isLoading: false
  },
  mutations: {
    updateLoadingStatus (state, payload) {
      state.isLoading = payload.isLoading
    }
  }
}) 

import routes from './config/router.js'
const router = new VueRouter({
	routes: routes.routes
})

router.beforeEach(function (to, from, next) {
  store.commit('updateLoadingStatus', {isLoading: true})
  next()
})

router.afterEach(function (to) {
  setTimeout(()=> {
      store.commit('updateLoadingStatus', {isLoading: false})
  }, 300)

})

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app-box')
